package com.cy.service.impl;

import com.cy.dao.ArticleJDBCDAO;
import com.cy.entity.Article;
import com.cy.service.ArticleService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author : 残影
 * @Date: 2020-08-07 18:45
 */
public class ArticlleJDBCService implements ArticleService {
    @Resource
    private
    ArticleJDBCDAO articleJDBCDAO;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveArticle( Article article) {
        articleJDBCDAO.save(article);
        int a = 2/0;
    }

    @Override
    public void deleteArticle(Long id){
        articleJDBCDAO.deleteById(id);
    }

    @Override
    public void updateArticle(Article article){
        articleJDBCDAO.updateById(article);
    }

    @Override
    public Article getArticle(Long id){
        return articleJDBCDAO.findById(id);
    }

    @Override
    public List<Article> getAll(){
        return articleJDBCDAO.findAll();
    }
}
